<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>components-4 标签</title>
    <script type="text/javascript" src="../assests/js/vue.js"></script>
</head>
<body>
    <h1>components标签 组件实例</h1>
    <hr>
    <div id="app">
        <div v-bind:is="who"></div>
        <button v-on:click="changeComponents">changeComponents</button>
    </div>
    <script>
        var componentA = {
            template:`<p style="color:green;">我是componentA</p>`
        }
        var componentB = {
            template:`<p style="color:yellow;">我是componentB</p>`
        }
        var componentC = {
            template:`<p style="color:red;">我是componentC</p>`
        }
        var app = new Vue({
            el:"#app",
            data:{
                who:"componentC3"
            },
            components:{
                "componentA1":componentA,
                "componentB2":componentB,
                "componentC3":componentC,
            },
            methods:{
                changeComponents:function(){
                    if(this.who == "componentA1"){
                        this.who = "componentB2"
                    }else if(this.who == "componentB2"){
                        this.who = "componentC3"
                    }else{
                        this.who = "componentA1"
                    }
                }
            }
        });
    </script>
</body>
</html>